USE [Codeplus]
GO

/****** Object:  StoredProcedure [dbo].[NewEnquiry]    Script Date: 08/10/2011 00:35:16 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO




-- =============================================
-- Author:		<Sanjeet Sahay>
-- Create date: <August 6, 2011>
-- Description:	<Saves a new enquiry>
-- =============================================
ALTER PROCEDURE [dbo].[NewEnquiry]
	@firstName nvarchar(50),
	@lastName nvarchar(50),
	@email nvarchar(50),
	@phone nvarchar(50),
	@serviceCode varchar(20),
	@countryCode varchar(20),
	@countryName varchar(50), 
	@city varchar(50),
	@longitude float,
	@latitude float,
	@ipaddress varchar(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	declare @serviceId int
	
	set @serviceId = (select top 1 Id from Services where Code = @serviceCode)
	
	insert into Enquiry(ServiceId, 
							FirstName, 
							LastName, 
							EmailAddress, 
							PhoneNumber,
							City, 
							CountryCode, 
							CountryName, 
							Longitude, 
							Latitude, 
							[Timestamp],
							IPAddress)
			values(@serviceId, 
					@firstName, 
					@lastName, 					
					@email, 
					@phone,
					@city, 
					@countryCode, 
					@countryName, 
					@longitude, 
					@latitude, 
					getutcdate(),
					@ipaddress)
			
END




GO


